package com.youku.utils
{
   public class DropFrameTable extends Object
   {
      
      public function DropFrameTable(param1:int = 0) {
         this._dft = new Array();
         super();
         this._len = param1;
         this.init();
      }
      
      private var _dft:Array;
      
      private var _lastTotal:int = 0;
      
      private var _len:int = 0;
      
      private function init() : void {
         var _loc2_:Object = null;
         var _loc1_:* = 0;
         while(_loc1_ < this._len)
         {
            _loc2_ = new Object();
            _loc2_._id = _loc1_;
            _loc2_._total = 0;
            _loc2_._last = 0;
            this._dft.push(_loc2_);
            _loc1_++;
         }
      }
      
      public function get droppedFrames() : int {
         var _loc1_:* = 0;
         var _loc2_:* = 0;
         while(_loc2_ < this._dft.length)
         {
            _loc1_ = _loc1_ + this._dft[_loc2_]._total;
            _loc2_++;
         }
         return _loc1_;
      }
      
      public function updateLastTotal() : void {
         this._lastTotal = this.droppedFrames;
      }
      
      public function get difference() : int {
         var _loc1_:int = this.droppedFrames - this._lastTotal;
         this._lastTotal = this.droppedFrames;
         return _loc1_;
      }
      
      public function update(param1:int, param2:int) : void {
         if(param1 >= this._dft.length)
         {
            return;
         }
         if(this._dft[param1]._last <= param2)
         {
            this._dft[param1]._total = this._dft[param1]._total + (param2 - this._dft[param1]._last);
         }
         else
         {
            this._dft[param1]._total = this._dft[param1]._total + param2;
         }
         this._dft[param1]._last = param2;
      }
      
      public function clear() : void {
         this._dft = [];
         this._lastTotal = 0;
         this.init();
      }
   }
}
